let csrf = null;

function csrfToken() {
    let token = document.head.querySelector('meta[name="csrf-token"]');

    if (token) {
        csrf = token.content;
    } else {
        console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
    }
}

export const getCsrf = () => {
    return csrf || csrfToken();
};
